package algoU1A1;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionAdapter;

import javax.swing.JComponent;
import javax.swing.JFrame;

public class Farbverlauf extends JFrame {
	JComponent farbverlauf;
	Color upperLeft,upperRight,lowerLeft,lowerRight;
	int mouseX,mouseY;
	Color[][] paintMatrix;
	
	void initPaintMatrix(int nrOfHorizontalPixels,int nrOfvertivalPixels){
		
	}
	
	Farbverlauf(Color upperLeft, Color upperRight, Color lowerLeft , Color lowerRight) {
		setSize(800, 400);
		mouseX=mouseY=5;
		this.upperLeft=upperLeft;
		this.upperRight=upperRight;
		this.lowerLeft=lowerRight;
		this.lowerRight=lowerRight;
		add(farbverlauf = new JComponent() {
			{
				addMouseMotionListener(new MouseMotionAdapter() {
					@Override
					public void mouseMoved(MouseEvent e) {
						super.mouseMoved(e);
						mouseX=e.getX();mouseY=e.getY();
						System.out.println("Mousepointer@"+mouseX+"x"+mouseY);
						repaint();
					}
				});
			}

			public void paintComponent(Graphics g) {
//				System.out.println("Anzahl Pixel:" + getWidth());
//				// Inkrement = Farbdifferenz/Anzahl Pixel
//				float redincrement = (float) (Farbverlauf.this.end.getRed() - Farbverlauf.this.start
//						.getRed()) / (float) getWidth();
//				float greenincrement = (float) (Farbverlauf.this.end.getGreen() - Farbverlauf.this.start
//						.getGreen()) / (float) getWidth();
//				float blueincrement = (float) (Farbverlauf.this.end.getBlue() - Farbverlauf.this.start
//						.getBlue()) / (float) getWidth();
//
//				System.out.println("Increments:" + redincrement + ","
//						+ greenincrement + "," + blueincrement);
//
//				for (int x = 0; x < getWidth(); ++x) {
//					// Fortschrittswert = x*Inkrement
//					int red = (int) (x * redincrement);
//					int green = (int) (x * greenincrement);
//					int blue = (int) (x * blueincrement);
//					g.setColor(new Color(red, green, blue));
//					g.drawLine(x, 0, x, getHeight());
//				}
				initPaintMatrix(getWidth(),getHeight());
				
				for(int i=0;i<paintMatrix.length;++i){
					for(int j=0;j<paintMatrix[i].length;++j){
						g.setColor(paintMatrix[i][j]);
						g.drawLine(i,j,i,j);
					}
				}
			}
		});
		setVisible(true);
	}

	public static void main(String[] args) {
	}
}
